<html lang="zh">
<head>
    <link rel="icon" href="/static/images/title/air酱.ico" type="image/x-icon">
    <link rel="shortcut icon" href="/static/images/title/air酱.ico" type="image/x-icon">
    <meta charset="utf-8">
    <title>Air酱</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link href="/static/css/air-index.css" type="text/css" rel="stylesheet">
    <link href="/static/css/login.css" rel="stylesheet" type="text/css"/>
    <script src="/static/js/jquery-3.5.1.js" type="text/javascript"></script>
</head>
<body>
<div class="air-body">
    <div class="air-box">
        <div class="air-top-fix"></div>
        <div class="air-top">
            <a href="/" class="air-top-title">Air酱</a>
            <a href="/" class="air-top-a">首页</a>
            <a href="crawler" class="air-top-a">爬取机票</a>
            <a href="wechat" class="air-top-a">微信推送</a>
            <a id="login" href="login" class="air-top-a">登录</a>
        </div>
        <div class="air-top-fix"></div>
        <div class="air-center">
            <div class="login_box">
                <div class="login_l_img"><img src="/static/images/login-img.png"/></div>
                <div class="login">
                    <div class="login_logo"><a href="#"><img src="/static/images/login_logo.png"/></a></div>
                    <div class="login_name">
                        <p>欢迎使用Air酱</p>
                    </div>
                    <form method="post" action="logging" id="air-login">
                        {% csrf_token %}
                        <input name="username" type="text" value="用户名" onfocus="if (this.value==='用户名')this.value='';"
                               onblur="if(this.value===''){this.value='用户名'}">
                        <span id="password_text"
                              onclick="this.style.display='none';document.getElementById('password').style.display='block';document.getElementById('password').focus().select();">密码</span>
                        <input name="password" type="password" id="password" style="display:none;"
                               onblur="if(this.value===''){document.getElementById('password_text').style.display='block';this.style.display='none'}"/>
                        <input value="登录" style="width:45%; float: left;margin-right: 10%" type="submit">
                        <input id="register" value="注册" style="width:45%; margin-right: 0;background: #95d6f3;"
                               type="button">
                    </form>
                    <form method="post" action="register" id="air-register">
                        {% csrf_token %}
                        <input name="username" type="text" value="用户名" onfocus="if (this.value==='用户名')this.value='';"
                               onblur="if(this.value===''){
                                   this.value='用户名';
                               }else {
                                   let valueOf = document.getElementsByName('csrfmiddlewaretoken')[0].value
                                   $.post('name',{
                                       csrfmiddlewaretoken: valueOf,
                                       value
                                   },function(data) {
                                       msg = data.msg;
                                       var img = document.getElementById('air-img-username');
                                       if (msg==='true'){
                                           img.src = '/static/images/勾.svg';
                                           img.hidden = false;
                                       }else {
                                           img.src = '/static/images/叉.svg';
                                           img.hidden = false;
                                       }

                                   })
                               }">
                        <img src="/static/images/勾.svg" id="air-img-username" hidden="hidden" class="air-img-tip">
                        <span id="password_text1"
                              onclick="this.style.display='none';document.getElementById('password1').style.display='block';document.getElementById('password1').focus().select();">密码</span>
                        <input name="password" type="password" id="password1" style="display:none;"
                               onblur="if(this.value===''){document.getElementById('password_text1').style.display='block';this.style.display='none'}"/>
                        <input value="注册" style="width:45%; float: left;margin-right: 10%" type="submit">
                        <input id="back" value="返回登录" style="width:45%; margin-right: 0;background: #95d6f3;"
                               type="button">
                    </form>
                </div>
            </div>
            <div style="text-align:center;">
            </div>
        </div>
        <div class="air-down">

        </div>
    </div>


</div>


</body>
<script>
    window.onload = function cookie_load() {
        var acookie = document.cookie.split(';')
        let valueOf = document.getElementsByName('csrfmiddlewaretoken')[0].value
        let air_register = window.document.getElementById('air-register');
        air_register.hidden = true;
        var flag = 0;
        let login_id = document.getElementById('login');
        for (var i = 0; i < acookie.length; i++) {
            var strings = acookie[i].split('=');
            if (strings[0] === ' login-cookie') {
                flag = 1;
                $.post('logging', {
                    strings,
                    csrfmiddlewaretoken: valueOf
                }, function (data) {
                })
            }
        }
        if (flag === 0) {
            login_id.innerText = '登录';
            login_id.href = 'login';
        }

    }
</script>
<script src="/static/js/login_script.js" type="text/javascript"></script>
</html>